package alexAI;
import java.util.ArrayList;


public class HistoryTable {
	private ArrayList<int[][]> moves;
	private static final int[][] moveError = new int[-1][-1];
	private ArrayList<Integer> depth;
	private HistoryTable table;
	
	private HistoryTable (){
		moves = new ArrayList<int[][]>();
		depth = new ArrayList<Integer>();
	}
	
	public HistoryTable getInstance(){
		if (table == null)
			table = new HistoryTable();
		return table;
	}
	
	public int[][] getMove(int depth){
		int getID = -1;
		if(table.getDepth().size() < depth)
			return moveError;
		for (int i = 0; i < depth; i++)
			if (table.depth.get(i) == depth)
				getID = table.depth.get(i);
		return table.getMoves().get(getID);
	}
	
	private ArrayList<Integer> getDepth(){
		return this.depth;
	}
	
	private ArrayList<int[][]> getMoves(){
		return this.moves;
	}
	
	private void addMove(int[][] bestMove, int depth){
		this.moves.add(bestMove);
		this.depth.add(depth);
	}
	
	private void changeMove(int[][] bestMove, int depth){
		this.moves.set(depth, bestMove);
	}
	
	public void addMoveHistory(int[][] bestMove, int depth){
		this.table.addMove(bestMove, depth);
	}
	
	public void changeMoveHistory(int[][] bestMove, int depth){
		this.table.changeMove(bestMove, depth);
	}
	
	public int length(){
		return this.table.getDepth().size();
	}
	
	
	
}
